<!DOCTYPE html>
<html>
<head>
    <title>登录页面</title>
    <meta charset="utf-8"/>
    <link rel="stylesheet" type="text/css" href="common.css">
    <script type="text/javascript" src="common.js"></script>
    <script type="text/javascript">
        const baseUrl = "/api";
        window.onload = function () {
            $("_login").onclick = function () {
                const email = $("email").value;
                const password = $("password").value;
                if (!checkNotEmpty(email, "邮箱") || !checkNotEmpty(password, "密码")) {
                    return;
                }
                const loginDTO = {
                    "email": email,
                    "password": password
                };
                ajax({
                    type: "POST",
                    url: baseUrl + "/user/login",
                    dataType: "json",
                    data: loginDTO,
                    success: function (data) {
                        let resultData = checkResult(data);
                        if (resultData["success"]) {
                            // 登录成功，跳转到欢迎页面
                            window.open("welcome.html#" + resultData["data"]);
                        }
                    }
                });
            }
        }
    </script>
</head>
<body>
<ul class="content">
    <li>邮 箱：<input type="text" id="email"/></li>
    <li>密 码：<input type="password" id="password"/></li>
    <li><a id="_login">登 录</a></li>
    <li><a id="_register" onclick="window.open('register.html');">注册新账号</a></li>
</ul>
</body>
</html>